﻿//
// Created by bxc on 2022/12/13.
//

#include "SipClient.h"
#include "SipServerConfig.h"
#include "Utils/Log.h"
#include "RTSPStream.h"
//#include <vld.h>

#include <vld.h>
#include <windows.h>
using namespace BXC;

int main(int argc, char *argv[]) {
    LOGI("");

    srand((int)time(NULL));   //每次执行种子不同，生成不同的随机数

#if 1
	#if 1
		const char *serverIp = "14.23.158.106";
	#else
		const char *serverIp = "192.168.8.115";
	#endif
	int serverPort = 20000;
	const char *serverSipId = "44010600542006100007";
	const char *serverSipRealm = "4401060054";
	const char *serverSipPass = "Linkcm@12306";
	int serverSipTimeout = 0;
	int serverSipExpiry = 3600;
#else
	const char *serverIp = "192.168.8.87";
	int serverPort = 15060;
	const char *serverSipId = "34020000002000000001";
	const char *serverSipRealm = "3402000000";
	const char *serverSipPass = "123456789";
	int serverSipTimeout = 0;
	int serverSipExpiry = 3600;
#endif

    const char *clientUa = "BXC_gb28181Client";
    const char *clientIp = "192.168.8.87";
    int clientPort = 5099;
    const char *clientId = "44010600031317000154";
    int localRtpPort = 10011;// 本地RTP的推流端口
	const char* url = "rtsp://admin:link123456@192.168.8.88:554/Streaming/Channels/103";
    SipServerConfig serverConfig(serverIp,serverPort,serverSipId,serverSipRealm,serverSipPass,serverSipTimeout,serverSipExpiry);
    SipClientConfig clientConfig(clientUa,clientIp,clientPort,clientId,localRtpPort);

    SipClient client(&serverConfig,&clientConfig, url);
	// 创建线程，使用 Lambda 表达式
	//std::thread worker([&]() {
	//	// 模拟一些工作
	//	std::this_thread::sleep_for(std::chrono::seconds(30));
	//	//Sleep(30);
	//	clientConfig.set_quit(true);
	//	
	//	});
    client.loop();
	//Sleep(5);
	/*std::this_thread::sleep_for(std::chrono::seconds(5));*/
    return 0;
}